home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 441 / dlibs12 / fclose.c < prev    next >
C/C++ Source or Header  |  1990-11-23  |  551b  |  27 lines

  1. #include <osbind.h>
  2. #include <stdio.h>
  3.  
  4. int fclose(fp)
  5.     register FILE *fp;
  6.     {
  7.     register int f;
  8.  
  9.     if(fp == NULL)
  10.         return(EOF);        /* NULL file pointer file */
  11.     f = fp->_flag;
  12.     if((f & (_IOREAD | _IOWRT)) == 0)
  13.         return(EOF);        /* file not open! */
  14.     fflush(fp);
  15.     if(fp->_bsiz != BUFSIZ)        /* throw away non-standard buffer */
  16.         {
  17.         fp->_base = NULL;
  18.         fp->_ptr = NULL;
  19.         fp->_bsiz = 0;
  20.         }
  21.     fp->_flag = 0;            /* clear status */
  22.     if(f & _IODEV)            /* leave tty's alone */
  23.         return(0);
  24.     f = close(fp->_file);
  25.     return(f ? EOF : 0);
  26.     }
  27.